/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package muddb.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 *
 * @author keith
 */
@Entity
@Table( name = "skill_group" )
@NamedQueries(
  {
    @NamedQuery( name = "SkillGroup.findBySkillGrpId",
                  query = "SELECT s FROM SkillGroup s WHERE s.skillGrpId = :skillGrpId" ),
    @NamedQuery( name = "SkillGroup.findBySkillGrpName",
                  query = "SELECT s FROM SkillGroup s WHERE s.skillGrpName = :skillGrpName" ) } )
public class SkillGroup implements Serializable {
  private static final long serialVersionUID = 1L;
  private Integer skillGrpId;
  private String skillGrpName;
  private Collection<SkillGroupProf> skillGroupProfCollection;
  private Collection<Skill> skillCollection;


  public SkillGroup() {
  }


  public SkillGroup( Integer skillGrpId ) {
    this.skillGrpId = skillGrpId;
  }


  public SkillGroup( String skillGrpName ) {
    this.skillGrpName = skillGrpName;
  }


  public SkillGroup( Integer skillGrpId, String skillGrpName ) {
    this.skillGrpId = skillGrpId;
    this.skillGrpName = skillGrpName;
  }


  @Id
  @GeneratedValue( strategy=GenerationType.SEQUENCE )
  @Column( name = "skill_grp_id", nullable = false )
  public Integer getSkillGrpId() {
    return skillGrpId;
  }


  public void setSkillGrpId( Integer skillGrpId ) {
    this.skillGrpId = skillGrpId;
  }


  @Column( name = "skill_grp_name", nullable = false, length = 30, unique = true )
  public String getSkillGrpName() {
    return skillGrpName;
  }


  public void setSkillGrpName( String skillGrpName ) {
    this.skillGrpName = skillGrpName;
  }


  @OneToMany( cascade = CascadeType.ALL, mappedBy = "skillGroup" )
  public Collection<SkillGroupProf> getSkillGroupProfCollection() {
    return skillGroupProfCollection;
  }


  public void setSkillGroupProfCollection( Collection<SkillGroupProf> skillGroupProfCollection ) {
    this.skillGroupProfCollection = skillGroupProfCollection;
  }


  @OneToMany( cascade = CascadeType.ALL, mappedBy = "skillGroup" )
  public Collection<Skill> getSkillCollection() {
    return skillCollection;
  }


  public void setSkillCollection( Collection<Skill> skillCollection ) {
    this.skillCollection = skillCollection;
  }


  @Override
  public int hashCode() {
    int hash = 0;
    hash += ( skillGrpId != null ? skillGrpId.hashCode() : 0 );
    return hash;
  }


  @Override
  public boolean equals( Object object ) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if ( !( object instanceof SkillGroup ) ) {
      return false;
    }
    SkillGroup other = (SkillGroup) object;
    if ( ( this.skillGrpId == null && other.skillGrpId != null ) || ( this.skillGrpId != null && !this.skillGrpId.equals( other.skillGrpId ) ) ) {
      return false;
    }
    return true;
  }


  @Override
  public String toString() {
    return "muddb.entities.SkillGroup[skillGrpId=" + skillGrpId + "]";
  }

}
